import time

from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Firefox()
driver.implicitly_wait(10)
driver.get("http://129.211.129.101:9007/index.php?m=user&c=public&a=login")
driver.find_element(By.ID, "username").send_keys("lllljl")
driver.find_element(By.ID, "password").send_keys("bj0304BJA@")
driver.find_element(By.ID, "password").submit()

driver.find_element(By.LINK_TEXT, '账号设置').click()
driver.find_element(By.PARTIAL_LINK_TEXT, '个人资料').click()
driver.find_element(By.ID, 'true_name').send_keys('工具人')
driver.find_element(By.CSS_SELECTOR, '[value="1"]').click()

script = 'document.getElementById("date").removeAttribute("readonly")'
driver.execute_script(script)
driver.find_element(By.ID, 'date').clear()
driver.find_element(By.ID, 'date').send_keys('1996-09-05')
driver.find_element(By.ID, 'qq').clear()
driver.find_element(By.ID, 'qq').send_keys('213123213')
driver.find_element(By.CSS_SELECTOR, '[value="确认"]').click()

# 切换alert窗口
WebDriverWait(driver, 30, 0.5).until(expected_conditions.alert_is_present())
update_text = driver.switch_to.alert.text
print(update_text)
driver.switch_to.alert.accept()

driver.quit()
